/**
 *
 *
 * Created by vimer on 15/8/27.
 */




var childProcess = require("child_process")
var run_path = require("path");
console.log(process.cwd());
var cmdStr = process.cwd() + '/asset/bin/px_uploader.py --port "/dev/tty.usbmodemPX*,/dev/tty.usbmodem*"  ';

//var cmdStr = "python -v";
function doTask (command ,stdoutFun , stderrFun,callback){
    console.log(command);
    var mvn = childProcess.exec(command);
    var logs = "";
    mvn.stdout.on('data' ,function(data){
        var info = data.toString();
        stdoutFun(info);

    });
    mvn.stderr.on('data',function(data){
        //console.log(data.toString());
        stderrFun(data);
    });
    mvn.on('exit',function(data){
        //console.log(data);
        callback();
    });

}


function startFirmware(path,stdoutFun,stderrFun,callback){
    doTask(cmdStr + " " + path,stdoutFun,stderrFun,callback) ;
}

